<?php
	include_once('config.php');
	include_once('SystemOneAPI.php');
	$api_service_list = "http://systemone.uplb.edu.ph/api/auth/";
	$api = new SystemOneAPI($api_service_list, API_USERNAME, API_PASSWORD);
	
	$login_params = array( );
	$login_params['username'] = 'liphedra';
	$login_params['password'] = '0628192';
	//echo $login_params['username'].'<br />'.$login_params['password'].'<br />';
	$result = $api->execute('login', $login_params);

	if ($result) {
		$_SESSION['sessionInfo'] = $api->getSessionInfo();
		$api->close();

	} else {
		$error_message = $api->getLastError();
		$api->close();
		echo $error_message;
	}
	
	$service_list="http://202.92.144.6/api/ocm/";
	$api1 = new SystemOneAPI($service_list, API_USERNAME, API_PASSWORD);

	//we don't need to execute('login') again  if we saved the sessionInfo from the login routine
	$api1->setSessionInfo($_SESSION['sessionInfo']);

	$result = $api1->execute('registration_info');

	if ($result) {
	     //if you want to debug uncomment the following

	    $studentInfo = $result->{'studentInfo'};
	    echo "<br/>Student's firstName is " . $studentInfo->{'firstName'} ;
	    echo "<br/>Student's middlename is " . $studentInfo->{'middleName'} ;
		echo "<br/>Student's lastname is " . $studentInfo->{'lastName'} ;
		echo "<br/>Student's sex is " . $studentInfo->{'sex'} ;   //or $studentInfo->firstName;
		echo "<br/>Student's curriculumocde is " . $studentInfo->{'curriculumCode'} ;   //or $studentInfo->firstName;
		echo "<br/>Student's college is " . $studentInfo->{'college'} ;   //or $studentInfo->firstName;
		echo "<br/>Student's stfapBracket is " . $studentInfo->{'stfapBracket'} ;   //or $studentInfo->firstName;
		echo "<br/>finalized is " . $result->{'finalized'} ;   //or $studentInfo->firstName;
		echo "<br/>allowed units is " . $result->{'allowedUnits'} ;   //or $studentInfo->firstName;
		echo "<br/>total units is " . $result->{'totalUnits'} ;   //or $studentInfo->firstName;
		echo "<br/><br/>";
	
		$schedule = $result->{'schedule'};
		$count1=count($schedule);
		echo "<br/><br/>ENLISTED</br>";
?>	
		<table>
			<tr>
				<td>Course Code</td>
				<td>Section</td>
				<td>Lecture</td>
				<td>Laboratory</td>
				<td>Lecturer</td>
				<td>Instructor</td>
				<td>Units</td>
				<td>Slot Status</td>
				<td>Section Status</td>
				<td>Class Size</td>
			</tr>
			<tr>
		<?php for($i=0;$i<$count1;$i++){
		?>
				<td><?php echo $schedule[$i]->courseCode; ?>
				<td><?php echo $schedule[$i]->sectionName; ?>
				<td><?php echo $schedule[$i]->lecture; ?>
				<td><?php echo $schedule[$i]->laboratory; ?>
				<td><?php echo $schedule[$i]->lecturer; ?>
				<td><?php echo $schedule[$i]->instructor; ?>
				<td><?php echo $schedule[$i]->units; ?>
				<td><?php echo $schedule[$i]->slotStatus; ?>
				<td><?php echo $schedule[$i]->sectionStatus; ?>
				<td><?php echo $schedule[$i]->isLargeClass; ?>
			</tr>
<?php	
		}
	}
?>